package com.zzx.graduation.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Getter
@Setter
//@Proxy(lazy = true)//,默认开启懒加载
@Entity//jpa实体类和数据表映射
//@Table(name="tb_user")//指定和哪个表对应，省略就采用默认user
//@JsonIgnoreProperties(value = {"fans","visitors"})//需要一一列出需要忽略转json的属性，
// 还是在属性上面添加好一点
public class GroupChat {
    @Id//主键
    @GeneratedValue(strategy = GenerationType.IDENTITY)//自增主键
    private Integer id;

    @Column(name="group_name")
    private String groupName;//名称

    @Column(name="administrator_id")
    private Integer administratorId;//管理员


    @Column(name="user_str")
    private String userStr;//用户列表：形如user1ID & user2ID

    @Column(name="notice")
    private String notice;//公告

    @JsonIgnore
    @ToString.Exclude
    @JsonIgnoreProperties("groupSet")
    @ManyToMany(mappedBy = "groupSet")
    private Set<User> userSet = new HashSet<>();

    @Override
    public String toString() {
        return "GroupChat{" +
                "id=" + id +
                ", administratorId=" + administratorId +
                ", userStr='" + userStr + '\'' +
                ", notice='" + notice + '\'' +
                '}';
    }
}
